package i18n

import (
	"os"
	"errors"
	"io/ioutil"
	"encoding/json"
	"Encrypt/utility"
	"fmt"
)

type I18nConfig struct {
	OutputPathHello string
	FileNotExist string
	NoSourceFileSetNotice string
}


func GetI18nConfig(nation string) (I18nConfig,error) {
	if nation == ""{
		nation = "zh_CN"
	}
	var i18nConfig I18nConfig
	programePath,err := utility.GetProgrameDirectory()
	if err != nil{
		return i18nConfig,err
	}
	langFilaPath := programePath+"/i18n/"+nation+".json"
	_,err = os.Stat(langFilaPath)
	if err != nil{
		if os.IsNotExist(err){
			fmt.Println(err)
			return i18nConfig,errors.New("语言文件不存在,Language File Not exist")
		}
		return i18nConfig,err
	}
	file,err := ioutil.ReadFile(langFilaPath)
	json.Unmarshal(file,&i18nConfig)
	return i18nConfig,nil
}